package com.idis.managerApp.controller;

import com.idis.common.base.BaseController;
import com.idis.service.IntroService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Ming on 2018/1/30.
 */
@RestController
@RequestMapping("/api/admin/intro")
@Api(tags = "简介接口")
public class IntroController extends BaseController{

    @Autowired
    IntroService introService;

    @ApiOperation("获取简介")
    @GetMapping("/all")
    public Map findAll(){
        Map map=new HashMap();
        List list=new ArrayList();
        map.put("content",introService.findAll());
        list.add(map);
        return sendDate(list);
    }

    @ApiOperation("更新简介")
    @PostMapping("/update")
    public Map update(@ApiParam("简介内容")String introduction){
        Map map=new HashMap();
        if(introduction.equals("")){
            sendNull(map);
            return map;
        }
        addResult(map, String.valueOf(introService.update(introduction)));
        addMessage(map,"修改成功");
        return map;
    }

}
